package com.dime.basic.service.impl;

import java.util.List;

import com.dime.basic.api.domain.DimeBasecontraindication;
import com.dime.basic.api.domain.DimeBasecontraindicationcriterion;
import com.dime.basic.mapper.DimeBasecontraindicationMapper;
import com.dime.basic.mapper.DimeBasecontraindicationcriterionMapper;
import com.dime.basic.service.IDimeBasecontraindicationService;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 禁忌症基础Service业务层处理
 *
 * @author Tiny
 * @date 2023-10-11
 */
@Service
public class DimeBasecontraindicationServiceImpl implements IDimeBasecontraindicationService
{
    @Autowired
    private DimeBasecontraindicationMapper dimeBasecontraindicationMapper;

    @Autowired
    private DimeBasecontraindicationcriterionMapper dimeBasecontraindicationcriterionMapper;

    /**
     * 查询禁忌症基础
     *
     * @param id 禁忌症基础主键
     * @return 禁忌症基础
     */
    @Override
    public DimeBasecontraindication selectDimeBasecontraindicationById(String id)
    {
        return dimeBasecontraindicationMapper.selectDimeBasecontraindicationById(id);
    }

    /**
     * 查询禁忌症基础列表
     *
     * @param dimeBasecontraindication 禁忌症基础
     * @return 禁忌症基础
     */
    @Override
    public List<DimeBasecontraindication> selectDimeBasecontraindicationList(DimeBasecontraindication dimeBasecontraindication)
    {
        return dimeBasecontraindicationMapper.selectDimeBasecontraindicationList(dimeBasecontraindication);
    }

    /**
     * 新增禁忌症基础
     *
     * @param dimeBasecontraindication 禁忌症基础
     * @return 结果
     */
    @Override
    public int insertDimeBasecontraindication(DimeBasecontraindication dimeBasecontraindication)
    {
        dimeBasecontraindication.setId(IdUtils.fastUUID());
        dimeBasecontraindication.setCreateTime(DateUtils.getNowDate());
        dimeBasecontraindication.setCreateBy(SecurityUtils.getUsername());
        return dimeBasecontraindicationMapper.insertDimeBasecontraindication(dimeBasecontraindication);
    }

    /**
     * 修改禁忌症基础
     *
     * @param dimeBasecontraindication 禁忌症基础
     * @return 结果
     */
    @Override
    public int updateDimeBasecontraindication(DimeBasecontraindication dimeBasecontraindication)
    {
        dimeBasecontraindication.setUpdateBy(SecurityUtils.getUsername());
        dimeBasecontraindication.setUpdateTime(DateUtils.getNowDate());

        DimeBasecontraindicationcriterion dimeBasecontraindicationcriterion = new DimeBasecontraindicationcriterion();
        dimeBasecontraindicationcriterion.setCationcriterionId(dimeBasecontraindication.getId());
        dimeBasecontraindicationcriterion.setCationcriterionName(dimeBasecontraindication.getName());
        dimeBasecontraindicationcriterionMapper.updateDimeBasecontraindicationcriterionByCationcriterionId(dimeBasecontraindicationcriterion);

        return dimeBasecontraindicationMapper.updateDimeBasecontraindication(dimeBasecontraindication);
    }

    /**
     * 批量删除禁忌症基础
     *
     * @param ids 需要删除的禁忌症基础主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecontraindicationByIds(String[] ids)
    {
        return dimeBasecontraindicationMapper.deleteDimeBasecontraindicationByIds(ids);
    }

    /**
     * 删除禁忌症基础信息
     *
     * @param id 禁忌症基础主键
     * @return 结果
     */
    @Override
    public int deleteDimeBasecontraindicationById(String id)
    {
        return dimeBasecontraindicationMapper.deleteDimeBasecontraindicationById(id);
    }
}
